package com.baibei.ebec.sdk;

import android.content.Context;

/**
 * 接口工厂
 * Created by ChenRui on 2017/7/24 0024 14:32.
 */
public final class ApiFactory {

    private static ApiProvider instance;

    /**
     * 初始化接口
     *
     * @param applicationContext Application
     */
    public static void init(Context applicationContext) {
        if (instance == null) {
            synchronized (ApiFactory.class) {
                if (instance == null) {
                    instance = new ApiProviderImpl(applicationContext);
                }
            }
        }
    }


    public static ApiProvider getInstance() {
        if (instance == null) {
            throw new NullPointerException("请在Application里面调动方法：ApiFactory.init(applicationContext)初始化接口实例。");
        }

        return instance;
    }


}
